---
title: "Longitunial Analysis"
output:
  pdf_document: default
  html_document: default
---
Load Packages
```{r}
library(scales)
library(texreg)
library(stargazer)
library(performance)
library(see)
library(qqplotr)
require(lme4)
library(ggpubr)
theme_set(theme_pubr())
```

Load Data
```{r}
load("StateLeg_WeeklyCOVIDFacebookActivity.RData")


table(by_week$rpg)
by_week2=subset(by_week,rpg !="Independent White Men" & rpg !="Republican Men of Color" & rpg !="Republican Women of Color")

by_week2$rpg=as.character(by_week2$rpg)

by_week2$rpg=factor(by_week2$rpg,levels = c("Republican White Men","Democratic White Men","Republican White Women","Democratic White Women","Democratic Men of Color","Democratic Women of Color"))
table(by_week2$rpg)


```

#WEEKLY TRENDS
##Weekly Tabulations and Visuals -Race and Gender
```{r}
weeklyavg=by_week  %>% 
  group_by(poc, Date) %>%
  summarize(General_Posts =mean(General),COVID_Posts=mean(COVID), Danger_Posts=mean(Danger),SD_Posts=mean(SD),Partisan_Posts=mean(Partisan), Events_Posts=mean(Events),Gender_Posts=mean(Gender),Race_Posts=mean(Racial), Budget_Posts=mean(Budget))
names(weeklyavg)
colnames(weeklyavg)=c("Group","Week","All","COVID-19","Danger","Social Distance","Partisan","Events","Gender","Racial","Budget")

#Visualizations
p1=ggplot(data = weeklyavg, aes(x=Week, y=All, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="") +ggtitle("All") +theme(plot.title = element_text(size = 13)) +
  scale_x_date(date_labels="%b",date_breaks  ="1 month")


p2=ggplot(data = weeklyavg, aes(x=Week, y=`COVID-19`, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="") +ggtitle("COVID")+theme(plot.title = element_text(size = 13))  +
  scale_x_date(date_labels="%b",date_breaks  ="1 month")

p3=ggplot(data = weeklyavg, aes(x=Week, y=`Social Distance`, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Social Distancing")+theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  


p4=ggplot(data = weeklyavg, aes(x=Week, y=Events, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="") +ggtitle("COVID-Events")+theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  

p5=ggplot(data = weeklyavg, aes(x=Week, y=Partisan, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Partisan") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  



p6=ggplot(data = weeklyavg, aes(x=Week, y=Gender, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Women") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  

p7=ggplot(data = weeklyavg, aes(x=Week, y=Racial, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Racial") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  


p8=ggplot(data = weeklyavg, aes(x=Week, y=Danger, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Danger") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month") 

p9=ggplot(data = weeklyavg, aes(x=Week, y=Budget, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("Budger") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month") 

together <- ggarrange(p1, p2,p8, p3,p4,p5,p6,p7,p9, ncol = 2, nrow = 5,common.legend = TRUE, legend = "top",font.label = list(size=12),vjust = .5)
ggexport(together,filename = "Total Activity Analysis_RaceAndGender/weeklyplots_race_gender_all.pdf",height =9,width = 7 )



```

##Weekly Tabulations- Race Gender and Party -Counts
```{r}
weeklyavg=by_week2  %>% 
  group_by(rpg, Date ) %>%
  summarize(General_Posts =mean(General),COVID_Posts=mean(COVID), Danger_Posts=mean(Danger),SD_Posts=mean(SD),Partisan_Posts=mean(Partisan), Events_Posts=mean(Events),Gender_Posts=mean(Gender),Race_Posts=mean(Racial), Budget_Posts=mean(Budget))
names(weeklyavg)
colnames(weeklyavg)=c("Group","Week","All","COVID-19","Danger","Social Distance","Partisan","Events","Gender","Racial","Budget")


#Visualizations
p1=ggplot(data = weeklyavg, aes(x=Week, y=All, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="") +ggtitle("All") +theme(plot.title = element_text(size = 13)) +
  scale_x_date(date_labels="%b",date_breaks  ="1 month")


p2=ggplot(data = weeklyavg, aes(x=Week, y=`COVID-19`, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID") +theme(plot.title = element_text(size = 13))  +
  scale_x_date(date_labels="%b",date_breaks  ="1 month")

p3=ggplot(data = weeklyavg, aes(x=Week, y=`Social Distance`, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Social Distancing")+theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  


p4=ggplot(data = weeklyavg, aes(x=Week, y=Events, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="") +ggtitle("COVID-Events")+theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  

p5=ggplot(data = weeklyavg, aes(x=Week, y=Partisan, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Partisan") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  



p6=ggplot(data = weeklyavg, aes(x=Week, y=Gender, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Women") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  

p7=ggplot(data = weeklyavg, aes(x=Week, y=Racial, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Racial") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month") 

p8=ggplot(data = weeklyavg, aes(x=Week, y=Danger, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Danger") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month") 

p9=ggplot(data = weeklyavg, aes(x=Week, y=Budget, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("Budget") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month") 




together <- ggarrange(p1, p2,p8, p3,p4,p5,p6,p7, ncol = 2, nrow = 4,common.legend = TRUE, legend = "top",font.label = list(size=12),vjust = .5)
ggexport(together,filename = "Total Activity Analysis_RaceAndGenderAndParty_v1/weeklyplots_race_gender_party.pdf",height =9.5,width = 7.5)


together <- ggarrange(p1, p2,p9, ncol = 2, nrow = 2,common.legend = TRUE, legend = "top",font.label = list(size=12),vjust = .5)
ggexport(together,filename = "Total Activity Analysis_RaceAndGenderAndParty_v1/weeklyplots_budgetcomparison.pdf",height =8,width = 8)


together <- ggarrange(p2, ncol = 1, nrow = 1,common.legend = TRUE, legend = "top",font.label = list(size=12),vjust = .5)
ggexport(together,filename = "Total Activity Analysis_RaceAndGenderAndParty_v1/weeklyplots_covid.pdf",height =5,width = 7)


```
                 

##Weekly Tabulations- Race Gender and Party -proportions
```{r}
weeklyavg=by_week2  %>% 
  group_by(rpg, Date ) %>%
  summarize(COVID_Posts=mean(COVID_prop,na.rm=TRUE), Danger_Posts=mean(Danger_prop,na.rm=TRUE),SD_Posts=mean(SD_prop,na.rm=TRUE),Partisan_Posts=mean(Partisan_prop,na.rm=TRUE), Events_Posts=mean(Events_prop,na.rm=TRUE),Gender_Posts=mean(Gender_prop,na.rm=TRUE),Race_Posts=mean(Racial_prop,na.rm=TRUE), Budget_Posts=mean(Budget_prop,na.rm=TRUE))
names(weeklyavg)
colnames(weeklyavg)=c("Group","Week","COVID-19","Danger","Social Distance","Partisan","Events","Gender","Racial","Budget")


#Visualizations
p2=ggplot(data = weeklyavg, aes(x=Week, y=`COVID-19`, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID") +theme(plot.title = element_text(size = 13))  +
  scale_x_date(date_labels="%b",date_breaks  ="1 month")

p3=ggplot(data = weeklyavg, aes(x=Week, y=`Social Distance`, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Social Distancing")+theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  


p4=ggplot(data = weeklyavg, aes(x=Week, y=Events, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="") +ggtitle("COVID-Events")+theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  

p5=ggplot(data = weeklyavg, aes(x=Week, y=Partisan, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Partisan") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  



p6=ggplot(data = weeklyavg, aes(x=Week, y=Gender, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Women") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month")  

p7=ggplot(data = weeklyavg, aes(x=Week, y=Racial, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Racial") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month") 

p8=ggplot(data = weeklyavg, aes(x=Week, y=Danger, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("COVID-Danger") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month") 

p9=ggplot(data = weeklyavg, aes(x=Week, y=Budget, group=Group))+
  geom_line(aes(linetype=Group, color=Group))+
  scale_color_manual(values=c("red4","blue","red","cornflowerblue","darkturquoise","paleturquoise1"))+
  scale_linetype_manual(values = c("twodash","solid","twodash","solid","solid","solid"))+
  ylab("Weekly Average")+xlab("")+
  scale_fill_discrete(name="")+ggtitle("Budget") +theme(plot.title = element_text(size = 13))+
  scale_x_date(date_labels="%b",date_breaks  ="1 month") 




together <- ggarrange(p2,p9, ncol = 2, nrow = 2,common.legend = TRUE, legend = "top",font.label = list(size=12),vjust = .5)
ggexport(together,filename = "Total Activity Analysis_RaceAndGenderAndParty_v1/weeklyplots_prop_budgetcomparison.pdf",height =8,width = 8)


together <- ggarrange(p2, ncol = 1, nrow = 1,common.legend = TRUE, legend = "top",font.label = list(size=12),vjust = .5)
ggexport(together,filename = "Total Activity Analysis_RaceAndGenderAndParty_v1/weeklyplots_propcovid.pdf",height =5,width = 7)


```

  



#Data Manipulation and Cleaning
Pull out weekly counts to create delta and lag variables
```{r}
names(by_week)
weekly=by_week[,c(1:11,20,78)]
names(weekly)
weekly=subset(weekly,Time_1 > 9) #Start at Week 10 which is March 4-March 11, 2020 the week before the order came down
weekly$week=weekly$Time_1-10
names(weekly)
names(weekly)

general=weekly[,c(1,3,14)]
covid=weekly[,c(1,4,14)]
sd=weekly[,c(1,5,14)]
events=weekly[,c(1,6,14)]
partisan=weekly[,c(1,7,14)]
gender=weekly[,c(1,8,14)]
race=weekly[,c(1,9,14)]
danger=weekly[,c(1,10,14)]
budget=weekly[,c(1,11,14)]
```

Pull out all the demographic data to later marge back with the new delta and lag variables
```{r}
names(by_week)
demos=by_week[,-c(2:20,78)]
demos=subset(demos,!duplicated(Legislator))
```


Creating Lag and Delta Variables
```{r}
#Lag
general_final <- merge(general, transform(general, week=week+1, lag_General=General, General=NULL))
covid_final <- merge(covid, transform(covid, week=week+1, lag_covid=COVID, COVID=NULL))
sd_final <- merge(sd, transform(sd, week=week+1, lag_sd=SD, SD=NULL))
events_final <- merge(events, transform(events, week=week+1, lag_events=Events, Events=NULL))
partisan_final <- merge(partisan, transform(partisan, week=week+1, lag_partisan=Partisan, Partisan=NULL))
gender_final <- merge(gender, transform(gender, week=week+1, lag_gender=Gender, Gender=NULL))
race_final <- merge(race, transform(race, week=week+1, lag_race=Racial, Racial=NULL))
danger_final <- merge(danger, transform(danger, week=week+1, lag_danger=Danger, Danger=NULL))
budget_final<- merge(budget, transform(budget, week=week+1, lag_budget=Budget, Budget=NULL))



a=cbind(general_final,covid_final,sd_final,events_final,partisan_final,gender_final,race_final,danger_final,budget_final)

names(a) #remove duplicate columns
combined=a[,-c(5,6,9,10,13,14,17,18,21,22,25,26,29,30,33,34)]
names(combined) #Double Check

#Delta (change per week)
combined$general_delta=combined$General -combined$lag_General
combined$covid_delta=combined$COVID -combined$lag_covid
combined$sd_delta=combined$SD -combined$lag_sd
combined$events_delta=combined$Events -combined$lag_events
combined$partisan_delta=combined$Partisan -combined$lag_partisan
combined$gender_delta=combined$Gender -combined$lag_gender
combined$race_delta=combined$Racial -combined$lag_race
combined$danger_delta=combined$Danger- combined$lag_danger
combined$budget_delta=combined$Budget -combined$lag_budget

```

Merge count, lag, and delta variables data set with demographic data
```{r}
summary(demos$X.voteClinton2016)
final=merge(x=combined, y=demos, by= "Legislator") #merge data


final$peak1=NA
final$peak1=ifelse(final$week <3,1,0) #Before Week 13,which is March 25-March 31st 

final$peak2=NA
final$peak2=ifelse(final$week <4,1,0) #Before Week 14, which is April 1st-April 7th

final$peak3=NA
final$peak3=ifelse(final$week >10,1,0) #After Week 20, which is May 13-May 19

final$peak4=NA
final$peak4=ifelse(final$week >20,1,0) #After Week 30, which is July 22 -July 28



table(final$rpg)
final2=subset(final,rpg !="Independent White Men" & rpg !="Republican Men of Color" & rpg !="Republican Women of Color")
final2$rpg=as.character(final2$rpg)
table(final2$rpg)
final2$rpg=factor(final2$rpg,levels = c("Republican White Men","Democratic White Men","Democratic White Women","Democratic Men of Color","Democratic Women of Color"))
table(final2$rpg)
final2$rpg2=factor(final2$rpg,levels = c("Democratic White Women","Republican White Men","Democratic White Men","Democratic Men of Color","Democratic Women of Color"))

table(final2$rpg2)

```


#Random Effects Models

##BY RACE GENDER AND PARTY- White Republican Men as Reference

###Models Including Delta and Lag and Peak Interaction#3 ALL
```{r}
m1 <-glmer(General~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg +rescale(general_delta)+ rescale(lag_General) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4))) 

m2 <- glmer(COVID~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg +rescale(covid_delta)+ rescale(lag_covid) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4))) 


m3 <- glmer(SD~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg +  rescale(sd_delta)+ rescale(lag_sd) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m4 <-glmer(Events~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg + rescale(events_delta)+rescale(lag_events) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m5 <-glmer(Partisan~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg + rescale(partisan_delta)+rescale(lag_partisan) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m6 <-glmer(Gender~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg + rescale(gender_delta)+rescale(lag_gender) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m7 <-glmer(Racial~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg + rescale(race_delta)+rescale(lag_race) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m8 <-glmer(Danger ~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg + rescale(danger_delta)+rescale(lag_danger) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m9 <-glmer(Budget ~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg + rescale(budget_delta)+rescale(lag_budget) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

               
htmlreg(list(m1,m2,m8,m3,m4,m5,m6,m7,m9),caption = "Random Effects Model With Lag, Delta, and Peak 3 (By Race, Gender and Party)", file = "Total Activity Analysis_RaceAndGenderAndParty_v1/REM_peak3_racegenderparty.doc",single.row= FALSE,custom.header = NULL,
        stars = c(.01,.05,.1),
        custom.model.names = c("All","COVID","COVID-Dangers","COVID-Social Distancing","COVID-Events","COVID-Partisan","COVID-Gender","COVID-Race","Budget"),
        custom.coef.names = c("Constant","White Man Democrat","White Woman Republican","White Woman Democrat","MOC Democrat","WOC Democrat", "Senator","Age","Committee Chair","Trump 2016 Vote Share","Previous Vote Share","2019 Bill Sponsorship","Covid Rate per 100,000","% White","Population Density","% College Educated","Median Income", "GA Legislator","NV Legislator","NY Legislator","TX Legislator","Peak","Delta All","Lag All","Peak:White Man Dem","Peak:White Woman GOP","Peak:White Woman Dem","Peak: MOC Dem","Peak: WOC Dem","Delta COVID","Lag COVID","Delta Dangers","Lag Dangers","Delta SD","Lag SD","Delta Events","Lag Events","Delta Partisan","Lag Partisan","Delta Gender","Lag Gender","Delta Race","Lag Race","Delta Budget","Lag Budget"))


```


###Models Including Delta and Lag and Peak Interaction#4, ALL
```{r}
m8 <-glmer(General~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg +rescale(general_delta)+ rescale(lag_General) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4))) 

m9 <- glmer(COVID~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg +rescale(covid_delta)+ rescale(lag_covid) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4))) 

m10 <- glmer(SD~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg +  rescale(sd_delta)+ rescale(lag_sd) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m11 <-glmer(Events ~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg + rescale(events_delta)+rescale(lag_events) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m12 <-glmer(Partisan~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg + rescale(partisan_delta)+rescale(lag_partisan) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))


m13 <-glmer(Gender~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg + rescale(gender_delta)+rescale(lag_gender) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m14 <-glmer(Racial~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg + rescale(race_delta)+rescale(lag_race) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m15 <-glmer(Danger ~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg + rescale(danger_delta)+rescale(lag_danger) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m16 <-glmer(Budget ~ rpg+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg + rescale(budget_delta)+rescale(lag_budget) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

htmlreg(list(m8,m9,m15,m10,m11,m12,m13,m14,m16),caption = "Random Effects Model With Lag, Delta, and Peak 4 (By Race,Gender, and Party)", file = "Total Activity Analysis_RaceAndGenderAndParty_v1/REM_peak4_racegenderparty.doc",
        stars = c(.01,.05,.1),
        custom.model.names = c("All","COVID","COVID-Dangers","COVID-Social Distancing","COVID-Events","COVID-Partisan","COVID-Gender","COVID-Race","Budget"),
custom.coef.names = c("Constant","White Man Democrat","White Woman Republican","White Woman Democrat","MOC Democrat","WOC Democrat", "Senator","Age","Committee Chair","Trump 2016 Vote Share","Previous Vote Share","2019 Bill Sponsorship","Covid Rate per 100,000","% White","Population Density","% College Educated","Median Income", "GA Legislator","NV Legislator","NY Legislator","TX Legislator","Peak","Delta All","Lag All","Peak:White Man Dem","Peak:White Woman GOP","Peak:White Woman Dem","Peak: MOC Dem","Peak: WOC Dem","Delta COVID","Lag COVID","Delta Dangers","Lag Dangers","Delta SD","Lag SD","Delta Events","Lag Events","Delta Partisan", "Lag Partisan","Delta Gender","Lag Gender","Delta Race","Lag Race","Delta Budget","Lag Budget"))




#library(equatiomatic)

#extract_eq(m2)



```



##BY RACE GENDER AND PARTY- White Democrat Women Men as Reference

###Models Including Delta and Lag and Peak Interaction#3 ALL
```{r}
m1 <-glmer(General~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 +rescale(general_delta)+ rescale(lag_General) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4))) 

m2 <- glmer(COVID~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 +rescale(covid_delta)+ rescale(lag_covid) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4))) 

m3 <- glmer(SD~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 +  rescale(sd_delta)+ rescale(lag_sd) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m4 <-glmer(Events~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 + rescale(events_delta)+rescale(lag_events) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m5 <-glmer(Partisan~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 + rescale(partisan_delta)+rescale(lag_partisan) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m6 <-glmer(Gender~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 + rescale(gender_delta)+rescale(lag_gender) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m7 <-glmer(Racial~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 + rescale(race_delta)+rescale(lag_race) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m8 <-glmer(Danger ~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 + rescale(danger_delta)+rescale(lag_danger) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))


m9 <-glmer(Budget ~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak3+peak3 *rpg2 + rescale(budget_delta)+rescale(lag_budget) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))


               
htmlreg(list(m1,m2,m8,m3,m4,m5,m6,m7,m9),caption = "Random Effects Model With Lag, Delta, and Peak 3 (By Race, Gender and Party)", file = "Total Activity Analysis_RaceAndGenderAndParty_v1/REM_peak3_racegenderparty_whiteomendems_ref.doc",single.row= FALSE,custom.header = NULL,
        stars = c(.01,.05,.1),
        custom.model.names = c("All","COVID","COVID-Dangers","COVID-Social Distancing","COVID-Events","COVID-Partisan","COVID-Gender","COVID-Race","Budget"),
        custom.coef.names = c("Constant","White Man Republican","White Man Democrat","White Woman Republican","MOC Democrat","WOC Democrat", "Senator","Age","Committee Chair","Trump 2016 Vote Share","Previous Vote Share","2019 Bill Sponsorship","Covid Rate per 100,000","% White","Population Density","% College Educated","Median Income", "GA Legislator","NV Legislator","NY Legislator","TX Legislator","Peak","Delta All","Lag All","Peak:White Man GOP","Peak:White Man Dem","Peak:White Woman GOP","Peak: MOC Dem","Peak: WOC Dem","Delta COVID","Lag COVID","Delta Dangers","Lag Dangers","Delta SD","Lag SD","Delta Events","Lag Events","Delta Partisan","Lag Partisan","Delta Gender","Lag Gender","Delta Race","Lag Race","Delta Budget","Lag Budget"))
```


###Models Including Delta and Lag and Peak Interaction#4, ALL
```{r}
m8 <-glmer(General~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 +rescale(general_delta)+ rescale(lag_General) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4))) 

m9 <- glmer(COVID~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 +rescale(covid_delta)+ rescale(lag_covid) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4))) 

m10 <- glmer(SD~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 +  rescale(sd_delta)+ rescale(lag_sd) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m11 <-glmer(Events ~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 + rescale(events_delta)+rescale(lag_events) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m12 <-glmer(Partisan~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 + rescale(partisan_delta)+rescale(lag_partisan) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))


m13 <-glmer(Gender~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 + rescale(gender_delta)+rescale(lag_gender) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m14 <-glmer(Racial~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 + rescale(race_delta)+rescale(lag_race) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m15 <-glmer(Danger ~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 + rescale(danger_delta)+rescale(lag_danger) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))

m16 <-glmer(Budget ~ rpg2+senator+age_rescaled+leader_or_chair+X.voteTrump2016_resclaed+Last.Vote.Share+Bill.Sponsor.2019_rescaled+COVID.Rate.per.100.000_rescaled+perc_white+Population.Density..Per.sq.mile._rescaled+College_Educated_rescaled+median_income_rescaled+State+peak4+peak4 *rpg2 + rescale(budget_delta)+rescale(lag_budget) + (1 | week) + (1 |Legislator ), family = poisson(), data=final2,glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e4)))



htmlreg(list(m8,m9,m15,m10,m11,m12,m13,m14,m16),caption = "Random Effects Model With Lag, Delta, and Peak 4 (By Race,Gender, and Party)", file = "Total Activity Analysis_RaceAndGenderAndParty_v1/REM_peak4_racegenderparty_whiteomendems_ref.doc",
        stars = c(.01,.05,.1),
        custom.model.names = c("All","COVID","COVID-Dangers","COVID-Social Distancing","COVID-Events","COVID-Partisan","COVID-Gender","COVID-Race","Budget"),
custom.coef.names = c("Constant","White Man Republican","White Man Democrat","White Woman Republican","MOC Democrat","WOC Democrat", "Senator","Age","Committee Chair","Trump 2016 Vote Share","Previous Vote Share","2019 Bill Sponsorship","Covid Rate per 100,000","% White","Population Density","% College Educated","Median Income", "GA Legislator","NV Legislator","NY Legislator","TX Legislator","Peak","Delta All","Lag All","Peak:White Man GOP","Peak:White Man Dem","Peak:White Woman GOP","Peak: MOC Dem","Peak: WOC Dem","Delta COVID","Lag COVID","Delta Dangers","Lag Dangers","Delta SD","Lag SD","Delta Events","Lag Events","Delta Partisan", "Lag Partisan","Delta Gender","Lag Gender","Delta Race","Lag Race","Delta Budget","Lag Budget"))



```

